#ifndef PARSINGDIALOG_H
#define PARSINGDIALOG_H

#include <QtGui>

namespace Ui {
class ParsingDialog;
}

class AppDataLists : public QObject
{
    Q_OBJECT
public:
    AppDataLists(QObject *parent=0);
    
private:
    QList<qreal> _priority;
    QList<qreal> _curBW;
    QList<qreal> _reqBW;
    QList<qreal> _observedQ;
    QList<qreal> _observedQ_d;
    QList<qreal> _demandedQ;
    
    qreal _avgCurrBW;
    
    /*!
      This assumes the priority of this app never changes in the data
      */
    qreal __priority;
    
    quint64 _gid;
};



class ParsingDialog : public QDialog
{
	Q_OBJECT
	
public:
	explicit ParsingDialog(QWidget *parent = 0);
	~ParsingDialog();
	
private:
	/*!
	  How many discrete priority values
	  */
	int _quantnum;

	/*!
	  The range of priority values that each discrete quantized priority will cover.
	  = (max - min) / _qunatnum
	  */
	qreal _quantrange;

	/*!
	  How many items before starting the per app data in each line?

      1st numApp
      2nd ratio Overlapped
	  */
	int _offsetToPerappData;

	/*!
	  The min priority value during entire time
	  */
	qreal _globalMinPriority;

	/*!
	  The max priority value during entire time
	  */
	qreal _globalMaxPriority;

	QString _outfilename;
	

	/*!
	  Raw data
	  */
	QList<QStringList> _lines;


	void findGlobalMinMaxPriority();

	/*!
      Find out which quantization range this data belongs to

	  0 : lowest priority group
	  */
	int getQuantLevelFromPriority(qreal p);



    void m_parseData_PriorityAndWinsize(QFile &file);

    void m_parseData_Static_PriorityAndQualities(QFile &file);


    void m_parseSpecificItem(QTextStream *textout, const QString &dataitemname, int column=-1);
	
private slots:
	void on_btn_parse_clicked();
	
public slots:
	void init(const QString &filename);
	
private:
	Ui::ParsingDialog *ui;
};

#endif // PARSINGDIALOG_H
